home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power CD-ROM!! 8
/
Power CD-ROM 8.iso
/
os2
/
perf31
/
autodsav.cmd
next >
Wrap
OS/2 REXX Batch file
|
1994-10-27
|
5KB
|
192 lines
/* Save Desktop Directory & INIs*/
/*Copyright (c) 1994 CLEAR & SIMPLE, INC.*/
arg SaveInterval SaveDrive
if SaveInterval='' | SaveDrive='' then do
say 'The format of AutoDsav is as follows:'
say;say ' AutoDsav interval d:\directory'
say;say 'Where interval is the number of days to wait'
say 'between desk save operations. And d:\directory is'
say 'a fully qualified path where AutoDsav will save'
say 'the two alternating desktop backups.'
say;say 'For more information please see the documentation.'
say;say 'Press Enter to end...'
pull
exit
end /* Do */
ECHO OFF
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
today=date('U')
parse var today month.0 '/' day.0 '/' year.0; clock=time();
rc=SysFileTree(SaveDrive'\P21autod.*',autodir,'DT')
if autodir.0 < 2 then do;
If autodir.0=0 then do; call desks savedrive'\p21autod.1'; exit; end;
else do; call desks savedrive'\p21autod.2'; exit; end;
end;
else call datecheck
call ElimDir file.old
call desks file.old
exit
DateCheck:
say autodir.0
say autodir.1
say autodir.2
parse var autodir.1 year.1'/'month.1'/'day.1'/'tim.1 size.1 att.1 file.1
parse var autodir.2 year.2'/'month.2'/'day.2 '/'tim.2 size.2 att.2 file.2
call julian year.1 month.1 day.1
jdat.1=result
call julian year.2 month.2 day.2
jdat.2=result
call julian year.0 month.0 day.0
jdat.0=result
if jdat.1 < jdat.2 then do; old=1; latest=2; end
else do; old=2; latest=1; end
dif=jdat.0-jdat.latest
if year.0=year.old then dif = jdat.0-jdat.latest
else dif =8
if dif < saveInterval then do; say 'dif= 'dif 'no save necessary'; exit; end
else do; file.old=strip(file.old,'L'); say file.old; return; end
ElimDir:
Signal on Error
rc=RXQUEUE("Create", 'elimdirQ')
rc=RXQUEUE("Set", 'elimdirQ')
do queued()
pull
end /* do */
arg deaddir .
rc=SysFileTree(deaddir'\*.*',dirs,'BS', '*****', '-----')
do i=1 to dirs.0
parse var dirs.i daye timee sizee atte filee
push atte filee;
end /* do */
do Queued()
pull atte filee;
if pos('D', atte) = 2 then 'RD' filee
else 'del' filee '/N'
end /* do */
'RD' DEADDIR
RC=RXQUEUE('Delete', 'elimdirQ')
return
error:
say 'Errors have occured'
do queued()
pull
end /* do */
if RXQUEUE('Delete', 'elimdirQ')=0 then say 'queue deleted'
exit
Desks:
Arg toDrive
CALL getBOOT
call finddesk
/*if dialog then echo on*/
DIR20or21=DESKTOP
RC=SysFileTree(driveis'\'DIR20or21'\*.*', 'deskdirs', 'SDO')
xcopy driveis'\'DIR20or21'\*.* 'todrive'\dsk21sav\*.* /E/O >NUL'
restore.0 ='%1\os2\Xcopy 'todrive'\DSK21SAV %1\'DIR20or21'\*.* /E'
do k=1 to deskdirs.0
directorywithblanks='"'deskdirs.k'"'
'xcopy ' directorywithblanks todrive'\DK21'k'\*.* /E/O >NUL'
restore.k='%1\os2\Xcopy DK21'k directorywithblanks'\*.* /E/O'
end
"xcopy " driveis"\OS2\OS2*.INI" todrive '/t/h/o >NUL'
"attrib" todrive"\*.ini -s -r"
"copy " driveis"\CONFIG.SYS" TODRIVE"\ORIGINAL.SYS" '>NUL'
call SysFileDelete todrive'\deskrstr.cmd'
OUTFILE = TODRIVE'\DESKRSTR.CMD'
call lineout outfile,'rem'
call lineout outfile,'rem The format is: deskrstr c:'
call lineout outfile,'rem Where c: is the OS/2 Drive to receive the following files:'
call lineout outfile,'rem \OS2\OS2.INI - \OS2\OS2SYS.INI - and the DESKTOP directory'
call lineout outfile,'xcopy OS2.INI %1\OS2\OS2.INI /t/h/o'
call lineout outfile,'xcopy OS2SYS.INI %1\OS2\OS2SYS.INI /t/h/o'
call lineout outfile,restore.0
do i = 1 to deskdirs.0
call lineout outfile,restore.i
end
return
finddesk:
ctr=1
app='FolderWorkareaRunningObjects'
call sysIni 'SYSTEM', App,'ALL:', 'stem'
do i=1 to stem.0
if pos("\DESKTOP",stem.i) > 0 | pos("\OS!",stem.i) >'0' then found.ctr=stem.i
end
rc=SysFileTree(found.ctr,dirs,'D')
do i=1 to dirs.0
parse upper var dirs.i date time . . directory
directory=strip(directory,'L')
parse var directory driv'\' dname
parse var dname first rest
found.ctr=dname
birthdate.ctr=date '-' time
end /* Do */
desktop=found.ctr;
return
getBOOT:
bootdrive = Value('Path',,'OS2ENVIRONMENT')
parse upper var bootdrive bootdrive
Driveis = Substr(bootdrive,Pos('\OS2\SYSTEM',bootdrive)-2,2)
return
julian:
arg cyear cmonth cday
cmonth=strip(cmonth,'L',0)
if cyear // 4=0 & cyear // 200 \=0 then leap=1
else leap=0
mo.1=0
mo.2=31
mo.3=59+leap
mo.4=90+leap
mo.5=120+leap
mo.6=151+leap
mo.7=181+leap
mo.8=212+leap
mo.9=243+leap
mo.10=273+leap
mo.11=304+leap
mo.12=334+leap
DofYr=mo.cmonth+cday
if length(DofYr)=1 then dofyr='00'||dofyr
else if length(DofYr)=2 then dofyr='0'||dofyr
else if length(DofYr)\=3 then do; say date error; exit; end
jdate=right(cyear,2)||DofYr
return jdate